package org.reyton.dao.impl;

import org.hibernate.SessionFactory;
import org.reyton.dao.SysDictionaryDao;
import org.reyton.entity.SysDictionary;
import org.reyton.entity.SysEmployee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 数据字典表Dao实现类
 * Created by reyton on 16-12-4.
 */
@Repository("sysDictionaryDao")
public class SysDictionaryDaoImpl extends HibernateDaoSupport implements SysDictionaryDao {
    @Autowired
    @Qualifier("sessionFactory")
    public void setSuperSessionFactory(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }

    @Override
    public List<SysDictionary> find() {
        return (List<SysDictionary>)super.getHibernateTemplate().find("from SysDictionary ");
    }

    @Override
    public SysDictionary findById(int id) {
        return (SysDictionary)this.getHibernateTemplate().find("from SysDictionary where id = ?",id).get(0);
    }
}
